import { Space, Tag } from "antd";
import { ContentProps } from "./data";
import { forwardRef, useState } from "react";
import { ProDescriptions } from "@ant-design/pro-components";
import styles from './descriptionStyles.less';

const Content: React.FC<ContentProps> = (props, uploadRef) => {
  // const [props.checkedKeys, setprops.checkedKeys] = useState<React.Key[]>([]);
  const voltageTypeMap = new Map([
    [0, '230/400V Δ/Y'],
    [1, '400/690V Δ/Y'],
  ]);

  const motorRotationMap = new Map([
    [0, '顺时针'],
    [1, '逆时针'],
  ]);

  const connectionTypeMap = new Map([
    [0, 'Y'],
    [1, 'Δ'],
  ]);

  const is87HzMap = new Map([
    [0, '50Hz'],
    [1, '87Hz'],
  ]);



  return (
    <div>
      <ProDescriptions
        title={<div style={{ fontSize: '14px' }}>基础信息配置</div>}
        style={{ marginTop: '20px' }}
        contentStyle={{ lineHeight: 0.4 }}
        labelStyle={{ lineHeight: 0.4, color: 'grey' }}
        column={5}
        actionRef={props.actionRef}
        request={async() => {
          return Promise.resolve({
            success: true,
            data: {
              ratedVoltage: props.row.ratedVoltage,
              ratedCurrent: props.row.ratedCurrent,
              ratedPower: props.row.ratedPower,
              ratedPowerCoeff: props.row.ratedPowerCoeff,
              ratedFrequency: props.row.ratedFrequency,
              ratedSpeed: props.row.ratedSpeed,
              ratedTorque: props.row.ratedTorque,
              connectionType: connectionTypeMap.get(props.row.connectionType),
              is87Hz: is87HzMap.get(props.row.is87Hz),
            },
          });
        }}
        columns={[
          {
            title: "额定电压 P304 [V]",
            key: 'ratedVoltage',
            dataIndex: 'ratedVoltage',
          },
          {
            title: "额定电流 P305 [A]",
            key: 'ratedCurrent',
            dataIndex: 'ratedCurrent',
          },
          {
            title: "额定功率 P307 [kW]",
            key: 'ratedPower',
            dataIndex: 'ratedPower',
          },
          {
            title: "额定功率因数 P308",
            key: 'ratedPowerCoeff',
            dataIndex: 'ratedPowerCoeff',
          },
          {
            title: "额定频率 P310 [Hz]",
            key: 'ratedFrequency',
            dataIndex: 'ratedFrequency',
          },
          {
            title: "额定速度 P311 [rpm]",
            key: 'ratedSpeed',
            dataIndex: 'ratedSpeed',
          },
          {
            title: "额定转矩 P312 [Nm]",
            key: 'ratedTorque',
            dataIndex: 'ratedTorque',
          },
          {
            title: "连接类型 P133.0",
            key: 'connectionType',
            dataIndex: 'connectionType',
          },
          {
            title: "87Hz运行选择 P133.1",
            key: 'is87Hz',
            dataIndex: 'is87Hz',
          },


        ]}
      ></ProDescriptions>
      <ProDescriptions
        title={<div style={{ fontSize: '14px' }}>Motor Data</div>}
        // style={{ marginTop: '22px' }}
        contentStyle={{ lineHeight: 0.4 }}
        labelStyle={{ lineHeight: 0.4, color: 'grey' }}
        column={5}
        actionRef={props.actionRef}
        request={async() => {
          return Promise.resolve({
            success: true,
            data: {
              motorData1: props.row.motorData1,
              motorData2: props.row.motorData2,
              motorData3: props.row.motorData3,
              motorData4: props.row.motorData4,
              motorData5: props.row.motorData5,
              motorData6: props.row.motorData6,
              motorData7: props.row.motorData7,
              motorData8: props.row.motorData8,
              motorData9: props.row.motorData9,
              motorData10: props.row.motorData10,
              motorData11: props.row.motorData11,
              motorData12: props.row.motorData12,
              motorData13: props.row.motorData13,
              motorData14: props.row.motorData14,
              motorData15: props.row.motorData15,
            },
          });
        }}
        columns={[
          {
            title: "motorData[1] P341 [kg·m²]",
            key: 'motorData1',
            dataIndex: 'motorData1',
          },
          {
            title: "motorData[2] P344 [kg]",
            key: 'motorData2',
            dataIndex: 'motorData2',
          },
          {
            title: "motorData[3] P320",
            key: 'motorData3',
            dataIndex: 'motorData3',
          },
          {
            title: "motorData[4] P350",
            key: 'motorData4',
            dataIndex: 'motorData4',
          },
          {
            title: "motorData[5] P354",
            key: 'motorData5',
            dataIndex: 'motorData5',
          },
          {
            title: "motorData[6] P356",
            key: 'motorData6',
            dataIndex: 'motorData6',
          },
          {
            title: "motorData[7] P358",
            key: 'motorData7',
            dataIndex: 'motorData7',
          },
          {
            title: "motorData[8] P360",
            key: 'motorData8',
            dataIndex: 'motorData8',
          },
          {
            title: "motorData[9] P1825",
            key: 'motorData9',
            dataIndex: 'motorData9',
          },
          {
            title: "motorData[10] P1828",
            key: 'motorData10',
            dataIndex: 'motorData10',
          },
          {
            title: "motorData[11] P1829",
            key: 'motorData11',
            dataIndex: 'motorData11',
          },
          {
            title: "motorData[12] P1830",
            key: 'motorData12',
            dataIndex: 'motorData12',
          },
          {
            title: "motorData[13]",
            key: 'motorData13',
            dataIndex: 'motorData13',
          },
          {
            title: "motorData[14]",
            key: 'motorData14',
            dataIndex: 'motorData14',
          },
          {
            title: "motorData[15]",
            key: 'motorData15',
            dataIndex: 'motorData15',
          },
        ]}
      ></ProDescriptions>
    </div>
  );
};

const G120Content = forwardRef<unknown, ContentProps>(Content);

export default G120Content;